package com.henme.crm.dao.product;


import com.henme.crm.entity.product.ProductCategory;
import com.henme.crm.util.dao.IBaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ProductCategoryMapper extends IBaseMapper<ProductCategory> {
    String UPDATE_INDEXS="UPDATE t_product_category  SET indexs=#{indexs} WHERE id = #{id}";

    String SELECT_COUNTER="SELECT COUNT(0) from t_product_category  WHERE pid = #{pid}" ;
    @Update(UPDATE_INDEXS)
    public  void updateIndexs(@Param("id") long id, @Param("indexs") long indexs);

    //取所有的子节点
    public List<ProductCategory> listSub(@Param(value = "pid") Long pid) ;
    //取所有的节点   where (select count(1) from t_product_category where pid=s.pid )<=10 取得分组 TOP-N
    /*
    select * from t_product_category s where (select count(1) from t_product_category where pid=s.pid )<=20
        order by indexs asc
     */
    /*
        SELECT * from t_product_category order by pid,indexs
     */
    public List<ProductCategory> getAllList();

    @Select(SELECT_COUNTER)
    public  int listSubCount(@Param(value = "pid") Long pid) ;
}


